<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.fh.web.util.PropertiesReader"%>
<%
//退出地址
String doLogOutURL = PropertiesReader.getInstance("/shiro.properties").getValue("shiro.doLogOutURL");
%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<c:set var="sys_user" value="${sessionScope.sys_user}"/>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="inc.jsp"></jsp:include>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>统一门户管理平台</title>
<link href="${ctx}/images/logo-icon.png" rel="icon">
<script type="text/javascript">
var index_layout;
var index_tabs;
var index_tabsMenu;
var layout_west_tree;
var layout_west_tree_url = '';
var sessionInfo_userId = '${sys_user.userId}';
 if (sessionInfo_userId) {//如果没有登录,直接跳转到登录页面
	layout_west_tree_url = '../user/userPurViewList';
}else{
	window.location.href='../login';
} 
function maxHit(url,id,text,iconCls){
	var ur;
		ur = '..' + url+'?id='+id;
	
	addTab({
		url : ur,
		title : text
	});
}

function maxHitMode(url,purCode,text,iconCls){
	
	var ur;
		ur = '../' + url+'?purCode='+purCode;
	addTab({
		url : ur,
		title : text
	});
}
$(function() {
	
	index_layout = $('#index_layout').layout({
		fit : true
	});
	
	index_tabs = $('#index_tabs').tabs({
		fit : true,
		border : false
	});
	
	layout_west_tree = $('#layout_west_tree').tree({
		url : layout_west_tree_url,
		parentField : 'pid',
		lines : true,
		onClick : function(node) {
			if (node.attributes && node.attributes.url) {
				var url = '../..' + node.attributes.url+'?id='+node.id;
				addTab({
					url : url,
					title : node.text,
					iconCls : iconCls,
				});
			}
		},
		onLoadError:function(e){
			$.messager.alert('错误',"获取菜单失败，服务器错误！", 'error');
		}
	});
	
	loadData();
	
});
function loadData(){
	$.ajax({   
		url:layout_west_tree_url, 
		type:'post',
		async : false, //默认为true 异步  
		dataType:'json',
		error:function(){
			alert('服务器异常！');   
		},   
		success:function(data){ 	
			var str="<ul class='menu-one'>";
			var i=1;
			$.each(data, function (n, value) {
				if(value.pid==0){
					if(n==0){
						str+="<li class='num"+i+"'><div class='header'><span class='txt'><span class='img'></span><span class='font'>"+value.text+"</span></span><span class='arrow'></span></div><ul class='menu-two'>";
						i++;
					}else{
						
							str+="</ul></li><li class='num"+i+"'><div class='header'><span class='txt'><span class='img'></span><span class='font'>"+value.text+"</span></span><span class='arrow'></span></div><ul class='menu-two'>";
							i++;	
					}
				}else{
					//模块管理
					if(value.purType==2){
						str+=$.formatString('<li><a href="#" class="maxHit" onclick="maxHitMode(\'{0}\',\'{1}\',\'{2}\',\'{3}\')">'+value.text+'</a></li>',value.url,value.purCode,value.text,value.iconCls);
					}else{
						str+=$.formatString('<li><a href="#" class="maxHit" onclick="maxHit(\'{0}\',\'{1}\',\'{2}\',\'{3}\')">'+value.text+'</a></li>',value.url,value.id,value.text,value.iconCls);
					}
					
				}
				if(n==(data.length-1)){
					str+="</ul></li>";
				}
			})
			str+="</ul>";
			$("#easyui_accordion").html(str);
			var aMenuOneLi = $(".menu-one > li");
	var aMenuTwo = $(".menu-two");
	$(".menu-one > li > .header").each(function (i) {
		$(this).click(function () {
			if ($(aMenuTwo[i]).css("display") == "block") {
				$(aMenuTwo[i]).slideUp(300);
				$(aMenuOneLi[i]).removeClass("menu-show")
			} else {
				for (var j = 0; j < aMenuTwo.length; j++) {
					$(aMenuTwo[j]).slideUp(300);
					$(aMenuOneLi[j]).removeClass("menu-show");
				}
				$(aMenuTwo[i]).slideDown(300);
				$(aMenuOneLi[i]).addClass("menu-show")
			}
		});
	});
	$("#easyui_accordion.content .menu-two li").click(function(){
			//去除其他li样式
			$("#easyui_accordion.content .menu-two li").removeClass('clickde_li');
			//增加选中li样式
			$(this).addClass("clickde_li");
			
		});
		}
	});
}
function addTab(params) {
	var iframe = '<iframe src="' + params.url + '" frameborder="0" style="border:0;width:100%;height:99.5%;"></iframe>';
	var t = $('#index_tabs');
	var opts = {
		title : params.title,
		closable : true,
		iconCls : params.iconCls,
		content : iframe,
		border : false,
		fit : true
	};
	if (t.tabs('exists', opts.title)) {
		//t.tabs('select', opts.title);
		var index = index_tabs.tabs('getTabIndex', t.tabs('getTab',opts.title));
		var tab = index_tabs.tabs('getTab', index);
		if (tab.panel('options').closable) {
			index_tabs.tabs('close', index);
			}
		t.tabs('add', opts);
		//t.tabs('getTab',opts.title).panel('open').panel('refresh');
	} else {
		t.tabs('add', opts);
	}
}

function logout(){
	$.messager.confirm('提示','确定要退出?',function(r){
		if (r){
			window.location.href='<%=doLogOutURL%>';
		}
	});
}


function editUserPwd() {
	parent.$.modalDialog({
		title : '修改密码',
		width : 300,
		height : 250,
		href : '../user/editPwdPage',
		buttons : [ {
			text : '修改',
			handler : function() {
				var f = parent.$.modalDialog.handler.find('#editUserPwdForm');
				f.submit();
			}
		} ]
	});
}


	
</script>

</head>
<body>

	<div id="loading" style="position: fixed;top: -50%;left: -50%;width: 200%;height: 200%;background: #fff;z-index: 100;overflow: hidden;">
	<img src="${ctx}/style/images/ajax-loader.gif" style="position: absolute;top: 0;left: 0;right: 0;bottom: 0;margin: auto;"/>
	</div>
	<div id="index_layout">
		<div data-options="region:'north',border:false" style=" overflow: hidden;" >
			<div id="header">
			<span style="float: right; padding-right: 20px;">欢迎 <b></b> ${sys_user.userCode}&nbsp;&nbsp;| <!-- <a href="javascript:void(0)" onclick="editUserPwd()" style="color: #fff;text-decoration:none;">修改密码</a>&nbsp;&nbsp; -->
			<a href="javascript:void(0)" onclick="logout()" style="color: #fff;text-decoration:none;">安全退出</a> 
        	&nbsp;&nbsp;&nbsp;&nbsp;
    		</span>
    		<span class="header"></span>
    		</div>
		</div>
		<div data-options="region:'west'" title="主导航" style="width: 205px; overflow: hidden;overflow-y:auto;">
		<div class="easyui-accordion content" id="easyui_accordion" style="width:210px;">
		</div>
		</div>
		<!-- 
		<div data-options="region:'west',split:true" title="主导航" style="width: 210px; overflow: hidden;overflow-y:auto;">
			<div class="well well-small" style="padding: 5px 5px 5px 5px;">
				<ul id="layout_west_tree"></ul>
			</div>
		</div> -->
		<div data-options="region:'center'" style="overflow: hidden;">
			<div id="index_tabs" style="overflow: hidden;">
				<div title="首页" data-options="border:false" style="overflow: hidden;">
					<div style="padding:10px 0 10px 10px">
						<h2 class="light-info" icon-tip">welcome！</h2>
						<!--  
						<div class="light-info">
							<div class="light-tip icon-tip"></div>
							<div>welcome！</div>
						</div> -->
					</div>
				</div>
			</div>
		</div>
		<div data-options="region:'south',border:false" style="height: 30px;line-height:30px; overflow: hidden;text-align: center;background-color: #eee" >版权所有@凤凰资源平台 </div>
	</div>
	
	<!--[if lte IE 7]>
	<div id="ie6-warning"><p>您正在使用 低版本浏览器，在本页面可能会导致部分功能无法使用。建议您升级到 <a href="http://www.microsoft.com/china/windows/internet-explorer/" target="_blank">Internet Explorer 8</a> 或以下浏览器：
	<a href="http://www.mozillaonline.com/" target="_blank">Firefox</a> / <a href="http://www.google.com/chrome/?hl=zh-CN" target="_blank">Chrome</a> / <a href="http://www.apple.com.cn/safari/" target="_blank">Safari</a> / <a href="http://www.operachina.com/" target="_blank">Opera</a></p></div>
	<![endif]-->
	
	<style>
		/*ie6提示*/
		#ie6-warning{width:100%;position:absolute;top:0;left:0;background:#fae692;padding:5px 0;font-size:12px}
		#ie6-warning p{width:960px;margin:0 auto;}
	</style>
	
</body>
</html>